-
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Fix Scaleway deployment by replacing broken organization_info module (fixes #14846) #14848
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…ixes #14846) The scaleway_organization_info Ansible module is broken and returns empty data due to using a deprecated API endpoint (upstream issue ansible-collections/community.general#3782). This causes deployments to fail with "'NoneType' object has no attribute 'get'" error. Changes: - Replace broken scaleway_organization_info module with user prompt for Organization/Project ID - Use Scaleway Marketplace API for image lookup instead of broken scaleway_image_info module - Migrate from deprecated 'organization' parameter to modern 'project' parameter in scaleway_compute calls - Add support for SCW_DEFAULT_ORGANIZATION_ID environment variable - Provide clear instructions for finding Organization ID in console Technical details: - Scaleway's default project ID equals the organization ID - Marketplace API is public and doesn't require authentication - The 'project' parameter was added in community.general 4.3.0 Testing: - Added 4 new unit tests validating the fix - All 91 unit tests pass - Passes ansible-lint, yamllint, ruff, and shellcheck 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
|
Claude finished @dguido's task —— View job PR Review: Scaleway Deployment FixReview Progress
🔍 Overall AssessmentThis is a well-crafted fix that addresses a legitimate issue with broken upstream Ansible modules. The solution is pragmatic and follows established patterns in the Algo codebase. ✅ StrengthsCode Quality
Test Coverage
|
| assert 'organization: "{{' not in content, "Still using deprecated 'organization' parameter" | ||
|
|
||
| # Should use Marketplace API for image lookup | ||
| assert "api-marketplace.scaleway.com" in content, "Not using Scaleway Marketplace API for image lookup" |
Check failure
Code scanning / CodeQL
Incomplete URL substring sanitization High test
api-marketplace.scaleway.com
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI about 24 hours ago
To fix the problem, we should avoid using a simple substring check and instead parse any URLs in the YAML/content for their hostname, then explicitly check that the hostname is valid. Since the content is not necessarily structured, we should search for URLs in the content (using a regex to extract strings that look like URLs), parse them with urllib.parse.urlparse, and check their hostname. We'll then assert that at least one of the URLs is to "api-marketplace.scaleway.com". This will make the test more semantically correct and future-proof against false positives where the endpoint appears in an undesirable context.
In practice:
- Import
reandurllib.parse. - Find all HTTP(S) URLs in the file content using regex.
- Parse each candidate URL and collect their hostnames.
- Assert that "api-marketplace.scaleway.com" is found in the set of hostnames.
All changes occur in the test_scaleway_main_uses_project_parameter function in tests/unit/test_scaleway_fix.py.
-
Copy modified lines R15-R16 -
Copy modified lines R47-R50
| @@ -12,8 +12,9 @@ | ||
| from pathlib import Path | ||
|
|
||
| import yaml | ||
| import re | ||
| from urllib.parse import urlparse | ||
|
|
||
|
|
||
| def load_yaml_file(file_path): | ||
| """Load and parse a YAML file""" | ||
| with open(file_path) as f: | ||
| @@ -44,7 +44,10 @@ | ||
| assert 'organization: "{{' not in content, "Still using deprecated 'organization' parameter" | ||
|
|
||
| # Should use Marketplace API for image lookup | ||
| assert "api-marketplace.scaleway.com" in content, "Not using Scaleway Marketplace API for image lookup" | ||
| # More robust: look for URLs and check hostnames | ||
| urls = re.findall(r'https?://[^\s\'"]+', content) | ||
| hosts = [urlparse(u).hostname for u in urls if urlparse(u).hostname] | ||
| assert "api-marketplace.scaleway.com" in hosts, "Not using Scaleway Marketplace API for image lookup" | ||
|
|
||
| print("✓ Scaleway main.yml uses modern 'project' parameter") | ||
|
|
The CodeQL scanner flags domain string assertions as "incomplete URL substring sanitization" but these are test assertions checking that Ansible role files reference the correct URLs, not URL validation logic. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
This reverts commit c75a73e.
Summary
Fixes #14846 - Resolves Scaleway deployment failure caused by broken
scaleway_organization_infoAnsible module.Problem
The
scaleway_organization_infomodule from ansible-collections/community.general is broken and returns empty data ([]) when called. This is due to the module using a deprecated API endpoint. See upstream issue: ansible-collections/community.general#3782When users attempted to deploy to Scaleway, they encountered:
This occurred because the role tried to access
scaleway_org.scaleway_organization_info[0]['id']on an empty list.Solution
Instead of relying on the broken Ansible module, this PR:
scaleway_image_infomodule with direct API call to the public Marketplace APIprojectparameter - Updatesscaleway_computecalls to useprojectinstead of deprecatedorganizationparameterSCW_DEFAULT_ORGANIZATION_IDto skip the promptTechnical Details
api-marketplace.scaleway.com) is public and doesn't require authenticationprojectparameter was added toscaleway_computein community.general 4.3.0Changes
Modified Files
roles/cloud-scaleway/tasks/prompts.yml- Added organization/project ID promptroles/cloud-scaleway/tasks/main.yml- Removed broken modules, added Marketplace API lookup, updated to useprojectparametertests/unit/test_scaleway_fix.py- Added 4 new unit testsTesting
Unit Tests:
projectparameter usage, Marketplace API integration, organization ID collectionLinting:
Limitations
How to Test
To test this fix:
./algoand select Scaleway as the providerAlternatively, set environment variables:
Related Issues